package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.manager.inst.KiteOfferInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 通用连接类APN类型属性处理器
 */
public class GeneralApnTypeAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {

    @Autowired
    IQuerySceneInstService querySceneInstService;

    @Override
    public void after(KiteAttr attr, KiteInst inst, AttrData data) {
        KiteOfferInst offerInst = querySceneInstService.getMainOfferInst(data.getSceneInstId());
        String offerId = offerInst.getOfferId();
        //5G纯数据下拉值为‘互联网’，其他为‘APN共享’
        if("50040701".equals(offerId)){
            attr.getAttrValues().removeIf(targetAttr -> KiteStringUtils.equalsAny(targetAttr.getAttrValue(), "100007289"));
        }else {
            attr.getAttrValues().removeIf(targetAttr -> KiteStringUtils.equalsAny(targetAttr.getAttrValue(), "100003262"));
        }
        super.after(attr, inst, data);
    }
}
